const {
  customerCreated,
  customerUpdated,
  customerDeleted,
  customerList,
} = require('../../controllers/admin/customers')

const { verifyToken } = require('../../utils/jwt')

const Customers = (fastify, opts, done) => {
  fastify.post(
    '/customer/created',
    { preHandler: verifyToken },
    customerCreated
  )
  fastify.put(
    '/customer/updated/:customerId',
    { preHandler: verifyToken },
    customerUpdated
  )

  fastify.delete(
    '/customer/deleted/:customerId',
    { preHandler: verifyToken },
    customerDeleted
  )
  fastify.get('/customer/list', { preHandler: verifyToken }, customerList)
  done()
}

module.exports = Customers
